#
# TagGen - Gerador de personagens para Tagmar 2
# Copyright (C) 2007 Marcelo Lira dos Santos <setanta@gmail.com>
#
# taggen is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# taggen is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#

##########################################################################

BINFILE=taggen
GLADEFILE=data/taggen.glade
VERSION=`cat ChangeLog | grep -m 1 ^taggen| cut -d" " -f2`

CHANGELOG=ChangeLog
CHANGELOG_TMP=.ChangeLog.tmp
CHANGELOG_EDT=.ChangeLog.edit
CHANGELOG_BKP=.ChangeLog.backup
EMAIL ?= $$USER@`hostname -f`

DESTDIR ?= /
PREFIX ?= /usr

# default editor of user has not set "EDITOR" env variable
EDITOR ?= vim

##########################################################################

all:
	python setup.py build

help:
	@echo 'make cl              make new changelog entry (1)'
	@echo 'make release         create source tarball in "dist/"'
	@echo 'make install         install taggen into "$(PREFIX)"'
	@echo 'make uninstall       uninstall taggen from "$(PREFIX)"'
	@echo 'make clean           remove generated+temp+*.pyc files'
	@echo 'make distclean       do a "make clean" + remove "dist/"'
	@echo ''
	@echo '(1) Please set environment variable "EMAIL" to your e-mail address'

##########################################################################

cl:
	cp $(CHANGELOG) $(CHANGELOG_BKP)
	(echo "`date -R` <$(EMAIL)>" ; svn status | sed -f doc/dev/svncl.sed | \
	sort ; echo ""; cat $(CHANGELOG)) >$(CHANGELOG_EDT)
	cp $(CHANGELOG_EDT) $(CHANGELOG)
	$(EDITOR) $(CHANGELOG)
	diff -q $(CHANGELOG) $(CHANGELOG_EDT) && mv $(CHANGELOG_BKP) $(CHANGELOG) || true
	rm -f $(CHANGELOG_BKP) $(CHANGELOG_EDT)


##########################################################################

deb:
	dpkg-buildpackage -us -uc -rfakeroot

release: distclean
	python setup.py sdist

install:
	python setup.py install --root=$(DESTDIR) --prefix=$(PREFIX)

update-icons:
	gtk-update-icon-cache -f -i $(PREFIX)/share/pixmaps/

uninstall:
	@echo "##############################################################################"
	@echo "#  MAKE UNINSTALL STILL NOT READY FOR PRIME TIME, WILL DO MY BEST TO         #"
	@echo "#  REMOVE FILES INSTALLED BY taggen. WATCH INSTALL PROCESS AND REMOVE        #"
	@echo "#  THE REST OF THE PACKAGES MANUALLY TO COMPLETELY REMOVE taggen.            #"
	@echo "##############################################################################"
	rm -rf $(PREFIX)/share/taggen $(PREFIX)/share/pixmaps/taggen.png \
		$(PREFIX)/share/pixmaps/taggen \
		$(PREFIX)/share/applications/taggen.desktop $(PREFIX)/bin/taggen \
		$(PREFIX)/lib/python?.?/site-packages/taggen-$(VERSION).egg-info \
		$(PREFIX)/lib/python?.?/site-packages/taggen

##########################################################################

clean:
	python setup.py clean
	rm -f src/*.pyc src/*.bak src/taggen.py \
       MANIFEST PKG-INFO $(GLADEFILE)p{,.bak} \
       $(GLADEFILE).bak
	rm -rf build

debclean:
	fakeroot debian/rules clean

distclean: clean
	rm -rf dist
 
##########################################################################

.PHONY: all cl release install update-icons clean debclean distclean

##########################################################################


